﻿Imports System
Imports System.Collections.Generic
Imports System.ComponentModel.Composition
Imports System.Linq
Imports System.Text
Imports System.Windows
Imports System.Windows.Controls
Imports Contracts

<PartCreationPolicy(CreationPolicy.Shared)> _
    <Export("IWpfService", GetType(Contracts.IWpfService))> _
    <WpfService("SampleAddin")> _
    Public Class SampleAddinImpl
    Implements IWpfService

    Private _name As String = "Sample #1", _status As String
    Private _optionsUI As New SettingsUserControl()

    Public Sub New()
        Console.WriteLine("SampleAddinImpl starting up!")
    End Sub

    Public Event StatusUpdated As EventHandler Implements Contracts.IWpfService.StatusUpdated

    Public ReadOnly Property OptionsUserControl() As UserControl Implements Contracts.IWpfService.OptionsUserControl
        Get
            Return _optionsUI
        End Get
    End Property

    Public ReadOnly Property Name() As String Implements Contracts.IWpfService.Name
        Get
            Return _name
        End Get
    End Property

    Public ReadOnly Property TrayIcon() As System.Drawing.Icon Implements Contracts.IWpfService.TrayIcon
        Get
            Return My.Resources.SecurityLock
        End Get
    End Property

    Public ReadOnly Property Description() As String Implements Contracts.IWpfService.Description
        Get
            Return "This is a test to see how an addin can work"
        End Get
    End Property

    Public ReadOnly Property Author() As String Implements Contracts.IWpfService.Author
        Get
            Return "Arian T. Kulp"
        End Get
    End Property

    Public ReadOnly Property Version() As Version Implements Contracts.IWpfService.Version
        Get
            Return System.Reflection.Assembly.GetExecutingAssembly().GetName().Version
        End Get
    End Property

    Public ReadOnly Property AuthorUri() As Uri Implements Contracts.IWpfService.AuthorUri
        Get
            Return New Uri("http://www.ariankulp.com")
        End Get
    End Property

    Public Property Status() As String Implements Contracts.IWpfService.Status
        Get
            Return _status
        End Get
        Set(ByVal value As String)
            If value <> _status Then
                _status = value

                RaiseEvent StatusUpdated(Me, Nothing)
            End If
        End Set
    End Property

    Public Sub Initialize() Implements Contracts.IWpfService.Initialize
        _optionsUI.DataContext = Me
    End Sub

    Public Sub Start() Implements Contracts.IWpfService.Start
        Status = "Started"
    End Sub

    Public Sub [Stop]() Implements Contracts.IWpfService.Stop

    End Sub

    Public ReadOnly Property HideOnClose() As Boolean Implements Contracts.IWpfService.HideOnClose
        Get
            Return True
        End Get
    End Property

End Class
